﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Remoting_Test {
    class Program {
        static void Main(string[] args) {

            AE.Remoting.Settings.Current.RemotingHost = "localhost";
            using (new AE.Remoting.Service()) { // In this case, we're acting as the host
                 
                double x = 2;
                double y = 3;
                double z = 0;

                //Example of an anonymous method and maintaining context
                AE.Remoting.Utilities.Remote(() => {
                    z = Math.Pow(x, y);
                });
                Console.WriteLine(z);


                //Example of an anonymous type  
                var result = AE.Remoting.Utilities.Remote(() => new { x =x, y= y, answer = Math.Pow(x,y)  });
                Console.WriteLine(result.answer);


                //Example of maintaining the context
                Customer customer = new Customer();
                AE.Remoting.Utilities.Remote(customer.Save);
                Console.WriteLine(customer.ID);


            }

            Console.ReadLine();
        }

        public class Customer {
            public Guid ID { get; private set; }
            public void Save() {
                ID = Guid.NewGuid();
            }
        } 
    }
}
